<?php

namespace App\Http\Requests\Admin\Panx\Material;

use App\Http\Requests\ApiRequest;

/**
 * @property string name
 * @property string code
 * @property string specifications
 * @property string manufacturer
 * @property string sku
 * @property string buyer
 * @property string purchase_at
 * @property string remark
 */
class MaterialStoreRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'           => 'required|string|max:'.self::MAX_STRING,
            'code'           => 'required|string|max:'.self::MAX_STRING,
            'sku'            => 'required|int|min:1|max:'.self::MAX_INT,
            'specifications' => 'required|string|max:'.self::MAX_STRING,
            'manufacturer'   => 'required|string|max:'.self::MAX_STRING,
            'buyer'          => 'required|string|max:'.self::MAX_STRING,
            'purchase_at'    => 'required|date',
            'remark'         => 'nullable|string|max:'.self::MAX_STRING,
        ];
    }

    public function attributes()
    {
        return [
            'name' => trans('admin.material_name'),
            'code' => trans('admin.material_code'),
        ];
    }
}
